import Image

class BaseImage(object):
    def __init__(self):
        self.filename = ""
        self.image = None
    
    def load(self, filename):
        self.filename = filename
        self.image = Image.open(filename)
    
    def copy(self, image):
        self.image = image.image.copy()
    
    def show(self):
        self.image.show()
        
    def get_pixels(self):
        pixels = list(self.image.getdata())
        width, height = self.image.size
        pixels = [pixels[i * width:(i + 1) * width] for i in xrange(height)]
        return pixels
    
    def update_pixels(self, pixels):
        pix = []
        for i in range(len(pixels)):
            for j in range(len(pixels[i])):
                pix.append(pixels[i][j])
        self.image.putdata(pix)
    
    def rotate(self, angle):
        self.image = self.image.rotate(angle)
        
    
    